var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(d, c, b) {
    if (status == 0 && d == 0) {
        cm.dispose();
        return
    }(d == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        cm.dispose()
    } else {
        if (status === a++) {
            if (cm.getMap().getNumMonsters() > 0) {
                cm.playerMessage(5, "还有怪物没有消灭干净。");
                cm.playerMessage(-1, "还有怪物没有消灭干净。");
                cm.dispose();
                return
            }
            if (cm.haveItem(4034874, 1)) {
                cm.sendNormalTalk("已经获得了#t4034874#。返回#m800023015#向#p9112046#报告吧。", 16, 9112057, false, true)
            } else {
                cm.gainItem(4034874, 1);
                cm.sendNormalTalk("获得了#t4034874#。返回#m800023015#向#p9112046#报告吧。", 16, 9112057, false, true)
            }
        } else {
            if (status === a++) {
                cm.dispose();
                cm.warp(800023015, 4, false)
            }
        }
    }
};